$OpenBSD: patch-protocols_jabber_libiris_iris_jdns_jdns_sys_c,v 1.3 2014/11/01 21:09:43 zhuk Exp $
Make this stuff compile and work on OpenBSD.
Partly from net/psi port.
--- protocols/jabber/libiris/src/jdns/src/jdns/jdns_sys.c.orig	Thu Jun  5 09:25:17 2014
+++ protocols/jabber/libiris/src/jdns/src/jdns/jdns_sys.c	Wed Jul  9 15:45:21 2014
@@ -727,7 +727,7 @@ static int my_res_init()
 //   specify the platforms that have __res_state_ext
 //#ifdef __res_state_ext
 #if defined(JDNS_OS_MAC) || defined(JDNS_OS_FREEBSD) || \
-    defined(JDNS_OS_NETBSD) || defined (JDNS_OS_SOLARIS)
+    defined(JDNS_OS_NETBSD) || defined(JDNS_OS_OPENBSD) || defined (JDNS_OS_SOLARIS)
 # define USE_EXTEXT
 #endif
 
@@ -736,14 +736,20 @@ static jdns_dnsparams_t *dnsparams_get_unixsys()
 	int n;
 	jdns_dnsparams_t *params;
 
-#ifdef JDNS_MODERN_RES_API
+#if defined(__OpenBSD__)
+	n = my_res_init();
+#define RESVAR _res
+#define RESEXTVAR _res_ext
+#elif defined(JDNS_MODERN_RES_API)
 	struct __res_state res;
 	memset(&res, 0, sizeof(struct __res_state));
 	n = res_ninit(&res);
 #define RESVAR res
+#define RESEXTVAR res._u._ext
 #else
 	n = my_res_init();
 #define RESVAR _res
+#define RESEXTVAR _res._u._ext
 #endif
 
 	params = jdns_dnsparams_new();
@@ -753,23 +759,27 @@ static jdns_dnsparams_t *dnsparams_get_unixsys()
 		return params;
 
 	// nameservers - ipv6
-#ifdef __GLIBC__
-	for(n = 0; n < MAXNS && n < RESVAR._u._ext.nscount6; ++n)
+#if defined(__GLIBC__)
+	for(n = 0; n < MAXNS && n < RESEXTVAR.nscount6; ++n)
+#elif defined(__OpenBSD__)
+	for(n = 0; n < MAXNS; ++n)
 #else
-	for(n = 0; n < MAXNS && n < RESVAR._u._ext.nscount; ++n)
+	for(n = 0; n < MAXNS && n < RESEXTVAR.nscount; ++n)
 #endif
 	{
 		jdns_address_t *addr;
 		struct sockaddr_in6 *sa6;
 
-#ifdef USE_EXTEXT
+#if defined(__OpenBSD__)
+		sa6 = (struct sockaddr_in6 *)&RESEXTVAR.nsaddr_list[n];
+#elif defined(USE_EXTEXT)
 		// seems _ext.ext can be null in some cases...
-		if(RESVAR._u._ext.ext == NULL)
+		if(RESEXTVAR.ext == NULL)
 			break;
 
-		sa6 = ((struct sockaddr_in6 *)RESVAR._u._ext.ext) + n;
+		sa6 = ((struct sockaddr_in6 *)RESEXTVAR.ext) + n;
 #else
-		sa6 = RESVAR._u._ext.nsaddrs[n];
+		sa6 = RESEXTVAR.nsaddrs[n];
 #endif
 
 		if(sa6 == NULL)
@@ -833,13 +843,17 @@ static jdns_dnsparams_t *dnsparams_get_unix()
 {
 	jdns_dnsparams_t *params;
 
-	// prefer system calls over files
+	// prefer system calls over files where possible
+#ifdef JDNS_OS_OPENBSD
+	params = dnsparams_get_unixfiles();
+#else
 	params = dnsparams_get_unixsys();
 	if(params->nameservers->count == 0)
 	{
 		jdns_dnsparams_delete(params);
 		params = dnsparams_get_unixfiles();
 	}
+#endif
 
 	apply_hosts_file(params, "/etc/hosts");
 
